home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / smaltalk.lha / smalltalk-1.1.1 / stix / Window.st < prev    next >
Text File  |  1991-09-12  |  6KB  |  235 lines

  1. "======================================================================
  2. |
  3. | Copyright (C) 1990, 1991 Free Software Foundation, Inc.
  4. | Written by Steve Byrne.
  5. |
  6. | This file is part of GNU Smalltalk.
  7. |
  8. | GNU Smalltalk is free software; you can redistribute it and/or modify it
  9. | under the terms of the GNU General Public License as published by the Free
  10. | Software Foundation; either version 1, or (at your option) any later version.
  11. | GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  12. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. | FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  14. | details.
  15. | You should have received a copy of the GNU General Public License along with
  16. | GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  17. | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  18. |
  19.  ======================================================================"
  20.  
  21.  
  22. "
  23. |     Change Log
  24. | ============================================================================
  25. | Author       Date       Change 
  26. | sbyrne     24 May 90      created.
  27. |
  28. "
  29.  
  30. Drawable subclass: #Window
  31.        instanceVariableNames: ''
  32.        classVariableNames: ''
  33.        poolDictionaries: ''
  34.        category: 'X hacking'
  35. !
  36.     
  37.  
  38. !Window class methodsFor: 'instance creation'!
  39.     
  40. new: aDisplay
  41.     ^self new init: aDisplay id: aDisplay nextId
  42. !
  43.  
  44. new: aDisplay id: anId
  45.     ^self new init: aDisplay id: anId
  46.     
  47. !!
  48.  
  49.  
  50. !Window methodsFor: 'X protocol'!
  51.  
  52. createWindow: depth x: x y: y width: width height: height
  53.     borderWidth: borderInteger class: aWindowClass visual: aVisual
  54.     attrs: aBlock
  55.     | packet win |
  56.     win _ Window new: display.
  57.  
  58.     packet _ XWindowAttrPacket command: 1 aux: depth.
  59.     packet long: win id; long: self id; word: x; word: y.
  60.     packet uword: width; uword: height; uword: borderInteger.
  61.     packet word: (X map: aWindowClass into: #(CopyFromParent InputOutput InputOnly)).
  62.     packet long: (X maybeMap: aVisual into: #(CopyFromParent)).
  63.  
  64.     aBlock notNil
  65.     ifTrue: [ aBlock value: packet ]
  66.     ifFalse: [ packet noBits ].
  67.  
  68.     display socket bytes: packet done.
  69.     ^win    
  70. !
  71.  
  72. changeWindowAttributes: aBlock
  73.     | packet |
  74.  
  75.     packet _ XWindowAttrPacket command: 2.
  76.     packet long: self id.
  77.     aBlock notNil
  78.     ifTrue: [ aBlock value: packet ]
  79.     ifFalse: [ packet noBits ].
  80.     display socket bytes: packet done
  81. !
  82.  
  83. getWindowAttributes
  84.     | packet |
  85.  
  86.     packet _ XPacket command: 3.
  87.     packet long: self id.
  88.     display socket bytes: packet done.
  89.     
  90.     ^packet getResultAuxByte: #(backingStore (NotUseful WhenMapped Always))
  91.     using: #((visual visualId)
  92.              (class (nil InputOutput InputOnly) word)
  93.              (bitGravity bitGravity)
  94.              (winGravity winGravity)
  95.              (backingPlanes card32)
  96.              (backingPixel card32)
  97.              (saveUnder bool)
  98.              (mapIsInstalled bool)
  99.              (mapState (Unmapped Unviewable Viewable) byte)
  100.              (overrideRedirect bool)
  101.              (colormap colormap (None))
  102.              (allEventMasks bitMask EventNames)
  103.              (yourEventMask bitMask EventNames)
  104.              (doNotPropagateMask bitMask DeviceEventNames))
  105. !
  106.  
  107. destroyWindow
  108.     | packet |
  109.     packet _ XPacket command: 4.
  110.     display socket bytes: (packet long: self id; done)
  111. !
  112.  
  113. destroySubwindows
  114.     | packet |
  115.     packet _ XPacket command: 5.
  116.     display socket bytes: (packet long: self id; done)
  117. !
  118.  
  119. changeSaveSet: mode
  120.     | packet |
  121.     packet _ XPacket command: 6 aux: (X map: mode into: #(Insert Delete)).
  122.     display socket bytes: (packet long: self id; done)
  123. !    
  124.  
  125. reparentWindow: parentWindow x: x y: y
  126.     | packet |
  127.     packet _ XPacket command: 7.
  128.     display socket bytes: (packet long: self id; long: parentWindow id; 
  129.                   word: x; word: y; done)
  130. !
  131.  
  132. mapWindow
  133.     | packet |
  134.     packet _ XPacket command: 8.
  135.     display socket bytes: (packet long: self id; done)
  136. !
  137.  
  138. mapSubwindows
  139.     | packet |
  140.     packet _ XPacket command: 9.
  141.     display socket bytes: (packet long: self id; done)
  142. !
  143.  
  144. unmapWindow
  145.     | packet |
  146.     packet _ XPacket command: 10.
  147.     display socket bytes: (packet long: self id; done)
  148. !
  149.  
  150. unmapSubwindows
  151.     | packet |
  152.     packet _ XPacket command: 11.
  153.     display socket bytes: (packet long: self id; done)
  154.  
  155. !
  156.  
  157. configureWindow: aBlock
  158.     | packet |
  159.     packet _ XConfigPacket command: 12.
  160.     
  161.     aBlock notNil
  162.     ifTrue: [ aBlock value: packet ]
  163.     ifFalse: [ packet noBits ].
  164.  
  165.     display socket bytes: packet doneWord
  166.     
  167. !
  168.  
  169. circulateWindow: direction
  170.     | packet |
  171.     packet _ XPacket command: 13 
  172.              aux: (X map: direction
  173.                  into: #(RaiseLowest LowerHighest)).
  174.     display socket bytes: (packet long: self id; done)
  175. !
  176.  
  177. queryTree
  178.     | packet result numWins wins s |
  179.     packet _ XPacket command: 15. 
  180.     display socket bytes: (packet long: self id; done).
  181.  
  182.     s _ display socket.
  183.     s getReply
  184.     ifFalse: [ ^self ].
  185.     
  186.     result _ Dictionary new.
  187.     result at: #root put: s mappedId.
  188.     result at: #parent put: (s maybeMappedId: #(None)).
  189.     numWins _ s word.
  190.     s skipBytes: 14.    "there should be a better way"
  191.     wins _ Array new: numWins.
  192.     1 to: numWins do:
  193.     [ :i | wins at: i put: (s mappedId) ].
  194.     result at: #children put: wins.
  195.     ^result
  196. !
  197.  
  198. "not really here ""
  199. internAtom: aString ifExists: aFlag
  200.     | packet |
  201.     packet _ XPacket command: 16 
  202.     aux: (aFlag ifTrue: [ 1 ] ifFalse: [ 0 ]).
  203.     display socket bytes: (packet string: aString; done).
  204.     ^self notYetImplemented
  205. ""needs to return some information"
  206.  
  207. changeProperty: propertyAtom type: anAtom mode: aMode format: formatByte data: data
  208.     | packet |
  209.     "### Not completely done yet: doesn't handle non-8 bit data"
  210.     packet _ XPacket command: 18
  211.              aux: (X map: aMode
  212.                  into: #(Replace Prepend Append)).
  213.     packet long: self id; long: propertyAtom mapToId; long: anAtom mapToId.
  214.     packet byte: formatByte; pad; long: (data size); bytes: data.
  215.     display socket bytes: (packet done)
  216. !
  217.  
  218. deleteProperty: propertyAtom
  219.     | packet |
  220.     packet _ XPacket command: 19.
  221.     display socket bytes: (packet long: self id; long: propertyAtom mapToId; done)
  222. !!
  223.  
  224. !Window methodsFor: 'private'!
  225.  
  226. init: aDisplay id: anId
  227.     display _ aDisplay.
  228.     id _ anId.
  229.     Registry at: id put: self
  230. !!
  231.  
  232.  
  233.